﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:System="clr-namespace:System;assembly=mscorlib"
    xmlns:Facebook="clr-namespace:Contigo;assembly=Contigo"
    xmlns:FacebookClient="clr-namespace:FacebookClient">

  <Color x:Key="FacebookBlue">#3b5998</Color>
  <SolidColorBrush x:Key="FacebookBlueBrush" Color="{StaticResource FacebookBlue}"/>

  <ControlTemplate x:Key="NotificationCountControlTemplate" TargetType="{x:Type FacebookClient:NotificationCountControl}">
    <Grid Width="17" Height="17" Visibility="{TemplateBinding Visibility}">
      <Ellipse Fill="{TemplateBinding Background}">
        <Ellipse.Effect>
          <DropShadowEffect Direction="-90" Opacity="0.75" ShadowDepth="1" BlurRadius="4" />
        </Ellipse.Effect>
      </Ellipse>
      <Viewbox Margin="0,3">
        <TextBlock Foreground="White" 
                   FontWeight="Normal" 
                   FontSize="9"
                   Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DisplayCount}" 
                   FontFamily="{DynamicResource SansSerifFont}" 
                   VerticalAlignment="Center" 
                   HorizontalAlignment="Center" />
      </Viewbox>
    </Grid>
  </ControlTemplate>

  <Style TargetType="{x:Type FacebookClient:NotificationCountControl}">
    <Setter Property="Template" Value="{StaticResource NotificationCountControlTemplate}" />
  </Style>

  <ControlTemplate x:Key="UpdateTextBoxTemplate" TargetType="{x:Type TextBox}">
    <ControlTemplate.Resources>
      <Storyboard x:Key="ShowGlowStoryboard">
        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="Glow" Storyboard.TargetProperty="(UIElement.Opacity)">
          <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="1" />
        </DoubleAnimationUsingKeyFrames>
      </Storyboard>
    </ControlTemplate.Resources>
    <Grid>
      <Rectangle x:Name="Glow" Fill="White" Opacity="0">
        <Rectangle.Effect>
          <BlurEffect Radius="14" />
        </Rectangle.Effect>
      </Rectangle>
      <Border x:Name="BoxBorder" Background="AliceBlue" BorderBrush="Gray" BorderThickness="2" CornerRadius="8" Padding="4,0,4,4">
        <Grid>
          <ScrollViewer x:Name="PART_ContentHost"
              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
              VerticalAlignment="Top"/>
          <TextBlock Foreground="Black"
              x:Name="Watermark"
              FontFamily="{TemplateBinding FontFamily}"
              FontSize="{TemplateBinding FontSize}"
              Text="{TemplateBinding Tag}"
              VerticalAlignment="Center"
              Margin="2,0,0,0"
              Visibility="Hidden"
              IsHitTestVisible="False" />
        </Grid>
      </Border>
    </Grid>

    <ControlTemplate.Triggers>
      <MultiTrigger>
        <MultiTrigger.Conditions>
          <Condition Property="IsFocused" Value="False" />
          <Condition Property="Text" Value="" />
        </MultiTrigger.Conditions>
        <Setter TargetName="Watermark" Property="Visibility" Value="Visible" />
      </MultiTrigger>
      <Trigger Property="IsKeyboardFocused" Value="True">
        <Trigger.EnterActions>
          <BeginStoryboard x:Name="ShowGlowStoryboard_BeginStoryboard" Storyboard="{StaticResource ShowGlowStoryboard}" />
        </Trigger.EnterActions>
        <Trigger.ExitActions>
          <StopStoryboard BeginStoryboardName="ShowGlowStoryboard_BeginStoryboard" />
        </Trigger.ExitActions>
      </Trigger>
      <Trigger Property="IsMouseOver" Value="True">
        <Trigger.EnterActions>
          <BeginStoryboard x:Name="ShowGlowStoryboard_BeginStoryboard1" Storyboard="{StaticResource ShowGlowStoryboard}" />
        </Trigger.EnterActions>
        <Trigger.ExitActions>
          <StopStoryboard BeginStoryboardName="ShowGlowStoryboard_BeginStoryboard" />
        </Trigger.ExitActions>
      </Trigger>
    </ControlTemplate.Triggers>
  </ControlTemplate>

  <Style x:Key="ApplicationBarShareTextBoxStyle" TargetType="TextBox">
    <Setter Property="SpellCheck.IsEnabled" Value="True" />
    <Setter Property="Template" Value="{StaticResource UpdateTextBoxTemplate}" />
    <Setter Property="FontSize" Value="{DynamicResource MiddleFontSize}" />
    <Setter Property="MinHeight" Value="20" />
    <Setter Property="VerticalAlignment" Value="Top" />
    <Setter Property="Margin" Value="20,20,0,20" />
    <Setter Property="TextWrapping" Value="Wrap" />
    <Setter Property="MaxHeight" Value="350" />
  </Style>

  <!-- Search Box -->
  <Style x:Key="SearchTextBoxStyle" TargetType="{x:Type FacebookClient:CommandTextBox}">
    <Setter Property="SpellCheck.IsEnabled" Value="True" />
    <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
    <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
    <Setter Property="AllowDrop" Value="true"/>
    <Setter Property="FontSize" Value="{DynamicResource MiddleFontSize}"/>
    <Setter Property="Foreground" Value="#FFFFFF"/>
    <Setter Property="Background" Value="#000000"/>
    <Setter Property="MaxLines" Value="1"/>
    <Setter Property="Height" Value="23"/>
    <Setter Property="TextWrapping" Value="NoWrap"/>
    <Setter Property="FontFamily" Value="{DynamicResource SansSerifFont}"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type FacebookClient:CommandTextBox}">
          <Grid x:Name="RootContainer">
            <Grid>
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="15" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="15" />
              </Grid.ColumnDefinitions>
              <Grid.RowDefinitions>
                <RowDefinition Height="9" />
                <RowDefinition Height="*" />
                <RowDefinition Height="9" />
              </Grid.RowDefinitions>

              <Border CornerRadius="6.5" Background="{DynamicResource SearchTextBoxBrush}" Grid.ColumnSpan="3" Grid.RowSpan="3" />
              <Border x:Name="FocusBacking" CornerRadius="6.5" Background="#FFFFFF" Grid.ColumnSpan="3" Grid.RowSpan="3" Opacity="0" />

              <Image Grid.Column="0" Source="../Images/Controls/text_box_top_left.png" Stretch="Fill" Margin="0,0,-0.1,0" />
              <Image Grid.Column="1" Source="../Images/Controls/text_box_top.png" Stretch="Fill"/>
              <Image Grid.Column="2" Source="../Images/Controls/text_box_top_right.png" Stretch="Fill" Margin="-0.1,0,0,0" />

              <Image Grid.Column="0" Grid.Row="1" Source="../Images/Controls/text_box_left.png" Stretch="Fill"/>
              <Image Grid.Column="2" Grid.Row="1" Source="../Images/Controls/text_box_right.png" Stretch="Fill"/>

              <Image Grid.Column="0" Grid.Row="2" Source="../Images/Controls/text_box_bottom_left.png" Stretch="Fill" Margin="0,0,-0.1,0" />
              <Image Grid.Column="1" Grid.Row="2" Source="../Images/Controls/text_box_bottom.png" Stretch="Fill"/>
              <Image Grid.Column="2" Grid.Row="2" Source="../Images/Controls/text_box_bottom_right.png" Stretch="Fill" Margin="-0.1,0,0,0" />
            </Grid>

            <Rectangle x:Name="Icon" Width="14" Height="13" HorizontalAlignment="Left" Margin="8,0,0,0" VerticalAlignment="Center"
                                   Fill="{DynamicResource SearchGlassLightDrawingBrush}"/>

            <Rectangle x:Name="Icon2" Width="14" Height="13" HorizontalAlignment="Left" Margin="8,0,0,0" VerticalAlignment="Center" Opacity="0"
                                   Fill="{DynamicResource SearchGlassDarkDrawingBrush}"/>

            <TextBlock x:Name="HelpText" Margin="30,1,0,0" VerticalAlignment="Center" HorizontalAlignment="Left" 
                                   FontFamily="{DynamicResource SansSerifFont}" FontWeight="Light" 
                                   Foreground="#FFFFFF" FontStyle="Italic" Text="{TemplateBinding BannerText}" 
                                   Visibility="Collapsed" FontSize="{DynamicResource MiddleFontSize}" />

            <ScrollViewer x:Name="PART_ContentHost" Margin="26,2,25,0" FontWeight="Medium"
                                      VerticalAlignment="Center" />
          </Grid>
          <ControlTemplate.Triggers>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="IsFocused" Value="False" />
                <Condition Property="Text" Value="" />
              </MultiTrigger.Conditions>
              <Setter TargetName="HelpText" Property="Visibility" Value="Visible"/>
            </MultiTrigger>
            <Trigger Property="IsFocused" Value="True">
              <Setter Property="Foreground" Value="#000000" />
              <Setter Property="Background" Value="#FFFFFF" />
            </Trigger>
            <Trigger Property="IsFocused" Value="False">
              <Setter Property="Foreground" Value="#FFFFFF" />
              <Setter Property="Background" Value="#000000" />
            </Trigger>
            <EventTrigger RoutedEvent="FrameworkElement.GotFocus">
              <EventTrigger.Actions>
                <BeginStoryboard>
                  <Storyboard>
                    <DoubleAnimation To="1" Duration="0:0:0.3" Storyboard.TargetName="FocusBacking" Storyboard.TargetProperty="Opacity" />
                    <DoubleAnimation To="1" Duration="0:0:0.3" Storyboard.TargetName="Icon2" Storyboard.TargetProperty="Opacity" />
                  </Storyboard>
                </BeginStoryboard>
              </EventTrigger.Actions>
            </EventTrigger>
            <EventTrigger RoutedEvent="FrameworkElement.LostFocus">
              <EventTrigger.Actions>
                <BeginStoryboard>
                  <Storyboard>
                    <DoubleAnimation To="0" Duration="0:0:0.3" Storyboard.TargetName="FocusBacking" Storyboard.TargetProperty="Opacity" />
                    <DoubleAnimation To="0" Duration="0:0:0.3" Storyboard.TargetName="Icon2" Storyboard.TargetProperty="Opacity" />
                  </Storyboard>
                </BeginStoryboard>
              </EventTrigger.Actions>
            </EventTrigger>
            <Trigger Property="IsEnabled" Value="false">
              <Trigger.EnterActions>
                <BeginStoryboard>
                  <Storyboard>
                    <DoubleAnimation To="0.5" Duration="0:0:0.1" Storyboard.TargetName="RootContainer" Storyboard.TargetProperty="Opacity"/>
                  </Storyboard>
                </BeginStoryboard>
              </Trigger.EnterActions>
              <Trigger.ExitActions>
                <BeginStoryboard>
                  <Storyboard>
                    <DoubleAnimation To="1" Duration="0:0:0.5" Storyboard.TargetName="RootContainer" Storyboard.TargetProperty="Opacity"/>
                  </Storyboard>
                </BeginStoryboard>
              </Trigger.ExitActions>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

  <!-- Status Box -->
  <Style x:Key="StatusTextBoxStyle" TargetType="{x:Type FacebookClient:CommandTextBox}">
    <Setter Property="SpellCheck.IsEnabled" Value="True" />
    <Setter Property="KeyboardNavigation.TabNavigation" Value="None"/>
    <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
    <Setter Property="AllowDrop" Value="true"/>
    <Setter Property="FontSize" Value="{DynamicResource MiddleFontSize}"/>
    <Setter Property="Foreground" Value="#FFFFFF"/>
    <Setter Property="Background" Value="#000000"/>
    <Setter Property="MinHeight" Value="23"/>
    <Setter Property="MaxHeight" Value="23"/>
    <Setter Property="TextWrapping" Value="Wrap"/>
    <Setter Property="AcceptsReturn" Value="True"/>
    <Setter Property="FontFamily" Value="{DynamicResource SansSerifFont}"/>
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="{x:Type FacebookClient:CommandTextBox}">
          <Grid x:Name="RootContainer">

            <Grid>
              <Grid.ColumnDefinitions>
                <ColumnDefinition Width="15" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="15" />
              </Grid.ColumnDefinitions>
              <Grid.RowDefinitions>
                <RowDefinition Height="9" />
                <RowDefinition Height="*" />
                <RowDefinition Height="9" />
              </Grid.RowDefinitions>

              <Border CornerRadius="6.5" Background="{DynamicResource StatusTextBoxBrush}" Grid.ColumnSpan="3" Grid.RowSpan="3" />
              <Border x:Name="FocusBacking" CornerRadius="6.5" Background="#FFFFFF" 
                                    Grid.ColumnSpan="3" Grid.RowSpan="3" Opacity="0" />

              <Image Grid.Column="0" Source="../Images/Controls/text_box_top_left.png" Stretch="Fill" Margin="0,0,-0.1,0" />
              <Image Grid.Column="1" Source="../Images/Controls/text_box_top.png" Stretch="Fill"/>
              <Image Grid.Column="2" Source="../Images/Controls/text_box_top_right.png" Stretch="Fill" Margin="-0.1,0,0,0" />

              <Image Grid.Column="0" Grid.Row="1" Source="../Images/Controls/text_box_left.png" Stretch="Fill"/>
              <Image Grid.Column="2" Grid.Row="1" Source="../Images/Controls/text_box_right.png" Stretch="Fill"/>

              <Image Grid.Column="0" Grid.Row="2" Source="../Images/Controls/text_box_bottom_left.png" Stretch="Fill" Margin="0,0,-0.1,0" />
              <Image Grid.Column="1" Grid.Row="2" Source="../Images/Controls/text_box_bottom.png" Stretch="Fill"/>
              <Image Grid.Column="2" Grid.Row="2" Source="../Images/Controls/text_box_bottom_right.png" Stretch="Fill" Margin="-0.1,0,0,0" />
            </Grid>

            <Rectangle x:Name="Icon" Width="14" Height="13" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="8,6,0,0" Visibility="Hidden" Fill="{DynamicResource BroadcastStatusDrawingBrush}"/>

            <TextBlock x:Name="HelpText" Margin="10,5,0,0" HorizontalAlignment="Left" 
                                   FontFamily="{DynamicResource SansSerifFont}" FontWeight="Light" 
                                   Foreground="#FFFFFF" Text="{TemplateBinding BannerText}" 
                                   Visibility="Collapsed" FontSize="{DynamicResource SmallFontSize1}"/>

            <ScrollViewer x:Name="PART_ContentHost" Margin="25,2,5,0" FontWeight="Medium" />
          </Grid>
          <ControlTemplate.Triggers>
            <MultiTrigger>
              <MultiTrigger.Conditions>
                <Condition Property="IsFocused" Value="False" />
                <Condition Property="Text" Value="" />
              </MultiTrigger.Conditions>
              <Setter TargetName="HelpText" Property="Visibility" Value="Visible"/>
            </MultiTrigger>
            <Trigger Property="IsFocused" Value="True">
              <Setter Property="Foreground" Value="#000000" />
              <Setter Property="Background" Value="#FFFFFF" />
              <Setter TargetName="Icon" Property="Visibility" Value="Visible" />
            </Trigger>
            <Trigger Property="IsFocused" Value="False">
              <Setter Property="Foreground" Value="#FFFFFF" />
              <Setter Property="Background" Value="#000000" />
              <Setter TargetName="Icon" Property="Visibility" Value="Hidden" />
            </Trigger>
            <EventTrigger RoutedEvent="FrameworkElement.GotFocus">
              <EventTrigger.Actions>
                <BeginStoryboard>
                  <Storyboard>
                    <DoubleAnimation To="1" Duration="0:0:0.3" Storyboard.TargetName="FocusBacking" Storyboard.TargetProperty="Opacity" />
                    <!--<DoubleAnimation To="1" Duration="0:0:0.3" Storyboard.TargetName="Icon2" Storyboard.TargetProperty="Opacity" />-->
                  </Storyboard>
                </BeginStoryboard>
              </EventTrigger.Actions>
            </EventTrigger>
            <EventTrigger RoutedEvent="FrameworkElement.LostFocus">
              <EventTrigger.Actions>
                <BeginStoryboard>
                  <Storyboard>
                    <DoubleAnimation To="0" Duration="0:0:0.3" Storyboard.TargetName="FocusBacking" Storyboard.TargetProperty="Opacity" />
                    <!--<DoubleAnimation To="0" Duration="0:0:0.3" Storyboard.TargetName="Icon2" Storyboard.TargetProperty="Opacity" />-->
                  </Storyboard>
                </BeginStoryboard>
              </EventTrigger.Actions>
            </EventTrigger>
            <Trigger Property="IsEnabled" Value="false">
              <Trigger.EnterActions>
                <BeginStoryboard>
                  <Storyboard>
                    <DoubleAnimation To="0.5" Duration="0:0:0.1" Storyboard.TargetName="RootContainer" Storyboard.TargetProperty="Opacity"/>
                  </Storyboard>
                </BeginStoryboard>
              </Trigger.EnterActions>
              <Trigger.ExitActions>
                <BeginStoryboard>
                  <Storyboard>
                    <DoubleAnimation To="1" Duration="0:0:0.5" Storyboard.TargetName="RootContainer" Storyboard.TargetProperty="Opacity"/>
                  </Storyboard>
                </BeginStoryboard>
              </Trigger.ExitActions>
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
  </Style>

</ResourceDictionary>
